package com.file.exercise;

import java.io.File;

/**
 * @author げっしょく
 * @date 2021/7/31
 */
public class Test8 {
    public static void main(String[] args) {
        File file = new File("Day12");
        System.out.println(countjava(file));
    }
    public static int countjava(File file){
        File[] files = file.listFiles();
        int count = 0;
        if (files != null) {
            for (File file1 : files) {
                if (file1.isFile()) {
                    if (file1.getName().endsWith(".java")) {
                        count++ ;
                    }
                }else{
                    count += countjava(file1);
                }
            }
        }
        return count;
    }
}
